import redis
r = redis.Redis(host='127.0.0.1', port=6379,db=0)
def demo():
    r.set('name', 'zhangsan')   #添加
    print (r.get('name'))   #获取
    pass
demo()
def usePool():
    pool = redis.ConnectionPool(host='127.0.0.1', port=6379)
    r = redis.Redis(connection_pool=pool)
    r.set('name', 'zhangsan')   #添加
    print (r.get('name'))   #获取
    pass

def usePipeline():
    pool = redis.ConnectionPool(host='127.0.0.1', port=6379)
    r = redis.Redis(connection_pool=pool)
    pipe = r.pipeline(transaction=True)
    r.set('name', 'zhangsan')
    r.set('name', 'lisi')
    pipe.execute()
    print (r.get("name"))
    pass

#usePipeline()

